home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / Container / Sources / Select.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  20.5 KB  |  711 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Select.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Container.hpp"
  11.  
  12. #ifndef SELECT_H
  13. #include "Select.h"
  14. #endif
  15.  
  16. #ifndef CONTENT_H
  17. #include "Content.h"
  18. #endif
  19.  
  20. #ifndef PART_H
  21. #include "Part.h"
  22. #endif
  23.  
  24. #ifndef FRAME_H
  25. #include "Frame.h"
  26. #endif
  27.  
  28. #ifndef PROXY_H
  29. #include "Proxy.h"
  30. #endif
  31.  
  32. #ifndef COMMANDS_H
  33. #include "Commands.h"
  34. #endif
  35.  
  36. #ifndef TRACKER_H
  37. #include "Tracker.h"
  38. #endif
  39.  
  40. // ----- Part Layer -----
  41.  
  42. #ifndef FWPRESEN_H
  43. #include "FWPresen.h"
  44. #endif
  45.  
  46. #ifndef FWITERS_H
  47. #include "FWIters.h"
  48. #endif
  49.  
  50. #ifndef FWCONTXT_H
  51. #include "FWContxt.h"
  52. #endif
  53.  
  54. #ifndef FWFCTCLP_H
  55. #include "FWFctClp.h"
  56. #endif
  57.  
  58. // ----- OS Layer -----
  59.  
  60. #ifndef SLMixOS_H
  61. #include "SLMixOS.h"
  62. #endif
  63.  
  64. // ----- OpenDoc Includes -----
  65.  
  66. #ifndef SOM_ODShape_xh
  67. #include <Shape.xh>
  68. #endif
  69.  
  70. #ifndef SOM_ODStorageUnit_xh
  71. #include <StorageU.xh>
  72. #endif
  73.  
  74. #ifndef SOM_Module_OpenDoc_StdProps_defined
  75. #include <StdProps.xh>
  76. #endif
  77.  
  78. //========================================================================================
  79. // Runtime Information
  80. //========================================================================================
  81.  
  82. #ifdef FW_BUILD_MAC
  83. #pragma segment odfcontainer
  84. #endif
  85.  
  86. //========================================================================================
  87. //    class CContainerSelection
  88. //========================================================================================
  89.  
  90. FW_DEFINE_AUTO(CContainerSelection)
  91.  
  92. //----------------------------------------------------------------------------------------
  93. //    CContainerSelection::CContainerSelection
  94. //----------------------------------------------------------------------------------------
  95.  
  96. CContainerSelection::CContainerSelection(Environment* ev, CContainerPart* part):
  97.     FW_CSelection(ev, false, false),    // no linking allowed
  98.     fContainerPart(part),
  99.     fUpdateShape(NULL),
  100.     fCount(0),
  101.     fSelectionContent(NULL),
  102.     fWorkingHandle(FW_kZeroRect, FW_kFill),
  103.     fDraggedContent(NULL)
  104. {
  105.     fSelectionContent = FW_NEW(CSelectionContent, (ev, part, this));
  106.     fWorkingHandle.SetInk(FW_kInvertInk);
  107.     FW_END_CONSTRUCTOR
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    CContainerSelection::~CContainerSelection
  112. //----------------------------------------------------------------------------------------
  113.  
  114. CContainerSelection::~CContainerSelection()
  115. {
  116.     FW_START_DESTRUCTOR
  117.     if (fUpdateShape)
  118.     {
  119.         FW_SOMEnvironment ev;
  120.         fUpdateShape->Release(ev);
  121.     }
  122. }
  123.  
  124. //----------------------------------------------------------------------------------------
  125. //    CContainerSelection::GetSelectedContent
  126. //----------------------------------------------------------------------------------------
  127.  
  128. FW_CContent* CContainerSelection::GetSelectedContent(Environment* ev)
  129. {
  130.     return fSelectionContent;
  131. }
  132.  
  133. //----------------------------------------------------------------------------------------
  134. //    CContainerSelection::WhichHandle
  135. //----------------------------------------------------------------------------------------
  136.  
  137. CProxy* CContainerSelection::WhichHandle(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& mouse, short& whichHandle) const
  138. {
  139.     whichHandle = 0;
  140.     
  141.     if (fCount != 0)
  142.     {
  143.         CContentProxyIterator ite(fSelectionContent);
  144.         for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  145.         {
  146.             whichHandle = proxy->WhichHandle(gc, mouse);
  147.             if (whichHandle != 0)
  148.                 return proxy;
  149.         }
  150.     }
  151.     
  152.     return NULL;
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    CContainerSelection::RenderSelectionHandles
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void CContainerSelection::RenderSelectionHandles(Environment* ev, FW_CGraphicContext& gc)
  160. {
  161.     CContentProxyIterator ite(fSelectionContent);
  162.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  163.     {
  164.         proxy->RenderHandles(gc);    
  165.     }
  166. }
  167.  
  168. //----------------------------------------------------------------------------------------
  169. //    CContainerSelection::RenderAllHandles
  170. //----------------------------------------------------------------------------------------
  171.  
  172. void CContainerSelection::RenderAllHandles(Environment* ev, FW_CFrame* frame)
  173. {
  174.     if (fCount != 0)
  175.     {        
  176.         FW_CFrameFacetIterator ite(ev, frame);
  177.         for (ODFacet* facet = (ODFacet*)ite.First(ev); ite.IsNotComplete(ev); facet = (ODFacet*)ite.Next(ev))
  178.         {
  179.             FW_CViewContext vc(ev, frame->GetContentView(ev), facet);
  180.             RenderSelectionHandles(ev, vc);
  181.         }
  182.     }
  183. }
  184.  
  185. //----------------------------------------------------------------------------------------
  186. //    CContainerSelection::RenderHandles
  187. //----------------------------------------------------------------------------------------
  188.  
  189. void CContainerSelection::RenderHandles(Environment* ev, CProxy* proxy)
  190. {
  191.     FW_CPresentationFrameIterator ite(ev, GetPresentation(ev));
  192.     for (FW_CFrame* frame = ite.First(ev); ite.IsNotComplete(ev); frame = ite.Next(ev))
  193.     {
  194.         if (frame->HasSelectionFocus(ev))
  195.         {
  196.             FW_CFrameFacetIterator i(ev, frame);            
  197.             for (ODFacet* facet = i.First(ev); i.IsNotComplete(ev); facet = i.Next(ev))
  198.             {
  199.                 FW_CViewContext vc(ev, frame->GetContentView(ev), facet);
  200.                 proxy->RenderHandles(vc);
  201.             }
  202.         }
  203.     }
  204. }
  205.  
  206. //----------------------------------------------------------------------------------------
  207. //    CContainerSelection::CloseSelection
  208. //----------------------------------------------------------------------------------------
  209.  
  210. void CContainerSelection::CloseSelection(Environment* ev)
  211. {
  212.     CProxy* proxy;
  213.     while ((proxy = fSelectionContent->GetFirstProxy()) != NULL)
  214.     {
  215.         DoRemove(ev, proxy);
  216.         RenderHandles(ev, proxy);        // turn off
  217.     }
  218.  
  219.     CalcCache(ev);
  220. }
  221.  
  222. //----------------------------------------------------------------------------------------
  223. //    CContainerSelection::AddToSelection
  224. //----------------------------------------------------------------------------------------
  225.  
  226. void CContainerSelection::AddToSelection(Environment* ev, CProxy* theProxy, FW_Boolean renderHandles)
  227. {                
  228.     if (theProxy != NULL)
  229.     {
  230.         DoAdd(ev, theProxy);
  231.         if (renderHandles)
  232.             RenderHandles(ev, theProxy);    // Turn on    
  233.     }        
  234.             
  235.     CalcCache(ev);
  236. }
  237.  
  238. //----------------------------------------------------------------------------------------
  239. //    CContainerSelection::RemoveFromSelection
  240. //----------------------------------------------------------------------------------------
  241.  
  242. void CContainerSelection::RemoveFromSelection(Environment* ev, CProxy* proxy, FW_Boolean renderHandles)
  243. {                
  244.     if (proxy != NULL)
  245.     {
  246.         DoRemove(ev, proxy);
  247.         if (renderHandles)
  248.             RenderHandles(ev, proxy);        // Turn Off
  249.     }    
  250.     
  251.     CalcCache(ev);
  252. }
  253.  
  254. //----------------------------------------------------------------------------------------
  255. //    CContainerSelection::DoAdd
  256. //----------------------------------------------------------------------------------------
  257.  
  258. void CContainerSelection::DoAdd(Environment* ev, CProxy* proxy)
  259. {
  260.     fSelectionContent->AddProxy(ev, proxy);
  261.     this->ProxyAdded(ev, proxy);
  262. }
  263.  
  264. //----------------------------------------------------------------------------------------
  265. //    CContainerSelection::ProxyAdded
  266. //----------------------------------------------------------------------------------------
  267. void CContainerSelection::ProxyAdded(Environment* ev, CProxy* proxy)
  268. {
  269.     proxy->SelectProxy(ev, true);
  270.     fCount++;
  271. }
  272.  
  273. //----------------------------------------------------------------------------------------
  274. //    CContainerSelection::DoRemove
  275. //----------------------------------------------------------------------------------------
  276.  
  277. void CContainerSelection::DoRemove(Environment* ev, CProxy* proxy)
  278. {
  279.     fSelectionContent->RemoveProxy(ev, proxy);
  280.     proxy->SelectProxy(ev, false);
  281.     fCount--;
  282. }
  283.  
  284. //----------------------------------------------------------------------------------------
  285. //    CContainerSelection::ClearSelection
  286. //----------------------------------------------------------------------------------------
  287.  
  288. void CContainerSelection::ClearSelection(Environment* ev)
  289. {
  290.     CProxy* proxy;
  291.     while ((proxy = fSelectionContent->GetFirstProxy()) != NULL)
  292.     {
  293.         DoRemove(ev, proxy);                        // Remove from selection list
  294.         fContainerPart->DetachProxy(ev, proxy);        // Remove from part
  295.     }
  296.     
  297.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  298.     facetClipper.Clip(ev, GetPresentation(ev), fUpdateShape);
  299.     GetPresentation(ev)->Invalidate(ev, fUpdateShape);
  300.     
  301.     CalcCache(ev);
  302. }
  303.  
  304. //----------------------------------------------------------------------------------------
  305. //    CContainerSelection::SelectAll
  306. //----------------------------------------------------------------------------------------
  307.  
  308. void CContainerSelection::SelectAll(Environment* ev)
  309. {    
  310.     FW_CFrame* activeFrame = fContainerPart->GetLastActiveFrame(ev);
  311.     
  312.     RenderAllHandles(ev, activeFrame);
  313.  
  314.     CContentProxyIterator ite(fContainerPart->GetPartContent());
  315.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  316.     {
  317.         if (!proxy->IsSelected())
  318.             DoAdd(ev, proxy);
  319.     }
  320.     
  321.     RenderAllHandles(ev, activeFrame);
  322.  
  323.     CalcCache(ev);
  324. }
  325.  
  326. //----------------------------------------------------------------------------------------
  327. //    CContainerSelection::IsEmpty
  328. //----------------------------------------------------------------------------------------
  329.  
  330. FW_Boolean CContainerSelection::IsEmpty(Environment* ev) const
  331. {    
  332.     return fCount == 0;
  333. }
  334.  
  335. //----------------------------------------------------------------------------------------
  336. //    CContainerSelection::CenterSelection
  337. //----------------------------------------------------------------------------------------
  338.  
  339. FW_CPoint CContainerSelection::CenterSelection(Environment* ev, FW_CFrame* scopeFrame)
  340. {
  341.     FW_ASSERT(scopeFrame);
  342.     
  343.     CalcCache(ev);
  344.     
  345.     FW_CRect bounds = scopeFrame->GetContentView(ev)->GetBoundsInContent(ev);
  346.     FW_CRect box(fDragRect);
  347.     box.PlaceInCenter(bounds);
  348.             
  349.     FW_CPoint result(box.left - fDragRect.left, box.top - fDragRect.top);
  350.     OffsetSelection(ev, result.x, result.y);
  351.     
  352.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  353.     facetClipper.Clip(ev, GetPresentation(ev), fUpdateShape);    
  354.     GetPresentation(ev)->Invalidate(ev, fUpdateShape);
  355.  
  356.     return result;
  357. }
  358.  
  359. //----------------------------------------------------------------------------------------
  360. //    CContainerSelection::Resize
  361. //----------------------------------------------------------------------------------------
  362.  
  363. FW_Boolean CContainerSelection::Resize(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  364. {    
  365.     if (fClickedHandle == 0)
  366.         return FALSE;
  367.         
  368.     if (!this->IsOKtoEdit(ev))    // can't resize read only part
  369.     {
  370.         FW_Beep();
  371.         return TRUE;
  372.     }
  373.                 
  374.     if (!theMouseEvent.WaitUntilMouseMoved(ev))
  375.         return TRUE;
  376.     
  377.     ODFacet* facet = theMouseEvent.GetFacet(ev);
  378.     FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  379.  
  380.     CProxy* anchorProxy = GetAnchorProxy();
  381.     
  382.     FW_CInk resizeInk(FW_kRGBBlack, FW_kRGBWhite, FW_kXOr);
  383.     FW_CStyle resizeStyle(FW_kFixed0, FW_kGrayPat);
  384.     
  385.     CResizeTracker resizeTracker(ev, frame->GetContentView(ev), facet, anchorProxy, fClickedHandle, resizeInk, resizeStyle);
  386.     if (resizeTracker.Track(ev, theMouseEvent))
  387.     {
  388.         GetPresentation(ev)->Invalidate(ev, fUpdateShape);
  389.  
  390.         FW_CPoint lastLocation;
  391.         resizeTracker.GetLastLocation(lastLocation);
  392.         FW_CRect srcRect, dstRect;
  393.         anchorProxy->GetMappedRects(fClickedHandle, lastLocation, srcRect, dstRect);
  394.  
  395.         CResizeCommand* cmd = FW_NEW(CResizeCommand,
  396.                                         (ev, fContainerPart, frame, this,
  397.                                          srcRect, dstRect));
  398.         cmd->Execute(ev);
  399.     }
  400.     else
  401.     {
  402.         FW_CViewContext vc(ev, frame->GetContentView(ev), facet);
  403.  
  404.         FW_CPoint penSize = vc.DeviceToLogical(2, 2);
  405.         anchorProxy->CalcHandle(fClickedHandle, &fWorkingHandle, penSize);
  406.         fWorkingHandle.Render(vc);    // redraw the handle
  407.     }
  408.     
  409.     return TRUE;
  410. }
  411.  
  412. //----------------------------------------------------------------------------------------
  413. //    CContainerSelection::CalcCache
  414. //----------------------------------------------------------------------------------------
  415.  
  416. void CContainerSelection::CalcCache(Environment* ev)
  417. {
  418.     fDragRect.Clear();
  419.     
  420.     if (fUpdateShape == NULL)
  421.         fUpdateShape = ::FW_NewODShape(ev);
  422.     
  423.     if (fCount == 0)
  424.         return;
  425.     
  426.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  427.     FW_CRect tempRect;
  428.  
  429.     FW_Boolean first = TRUE;
  430.     CContentProxyIterator ite(fSelectionContent);
  431.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  432.     {
  433.         tempRect = proxy->GetBounds(ev);
  434.         proxy->GetUpdateBox(ev, aqTempShape);
  435.         if (first)
  436.         {
  437.             fDragRect = tempRect;
  438.             fUpdateShape->CopyFrom(ev, aqTempShape);
  439.         }
  440.         else
  441.         {
  442.             fDragRect |= tempRect;
  443.             fUpdateShape->Union(ev, aqTempShape);
  444.         }
  445.                         
  446.         first = FALSE;
  447.     }
  448. }
  449.  
  450. //----------------------------------------------------------------------------------------
  451. //    CContainerSelection::CreateSelectionShape
  452. //----------------------------------------------------------------------------------------
  453.  
  454. ODShape* CContainerSelection::CreateSelectionShape(Environment* ev, ODFacet* facet, FW_CFrame* frame) const
  455. {
  456. FW_UNUSED(frame);
  457. FW_UNUSED(facet);
  458.  
  459.     ODShape* shape = ::FW_NewODShape(ev, fDragRect);
  460.     return shape;
  461. }
  462.  
  463. //----------------------------------------------------------------------------------------
  464. //    CContainerSelection::CreateSelectionOutline
  465. //----------------------------------------------------------------------------------------
  466.  
  467. ODShape* CContainerSelection::CreateSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame) const
  468. {
  469.     FW_ASSERT(GetAnchorProxy());
  470.     ODShape* outline = GetAnchorProxy()->CreateProxyOutline(ev);
  471.  
  472.     if (fCount > 1)
  473.     {
  474.         FW_CAcquiredODShape shapeOutline = FW_CSelection::CreateSelectionOutline(ev, facet, frame);
  475.         outline->Union(ev, shapeOutline);
  476.     }
  477.  
  478.     return outline;
  479. }
  480.  
  481. //----------------------------------------------------------------------------------------
  482. //    CContainerSelection::OffsetSelection
  483. //----------------------------------------------------------------------------------------
  484.  
  485. void CContainerSelection::OffsetSelection(Environment* ev, FW_Fixed xDelta, FW_Fixed yDelta)
  486. {
  487.     FW_CAcquiredODShape aqUnionShape(fUpdateShape->Copy(ev));
  488.     
  489.     CContentProxyIterator ite(fSelectionContent);
  490.     for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  491.     {
  492.         proxy->OffsetProxy(ev, xDelta, yDelta);
  493.     }
  494.     
  495.     CalcCache(ev);
  496.  
  497.     aqUnionShape->Union(ev, fUpdateShape);
  498.     
  499.     FW_CFacetClipper facetClipper(ev, fContainerPart);
  500.     facetClipper.Clip(ev, GetPresentation(ev), aqUnionShape);
  501. }
  502.  
  503. //----------------------------------------------------------------------------------------
  504. //    CContainerSelection::SelectWithRectangle
  505. //----------------------------------------------------------------------------------------
  506.  
  507. void CContainerSelection::SelectWithRectangle(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  508. {
  509.     FW_CStyle trackStyle(FW_kFixed0, FW_kAntPat);
  510.     FW_CInk trackInk(FW_kRGBBlack, FW_kRGBWhite, FW_kXOr);
  511.     CTrackRect rectShape(trackInk, trackStyle);    // Create a rect shape on the stack
  512.     
  513.     ODFacet* facet = theMouseEvent.GetFacet(ev);
  514.     FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  515.  
  516.     CSelectTracker tracker(ev, frame->GetContentView(ev), facet, &rectShape);
  517.     if (tracker.Track(ev, theMouseEvent))
  518.     {
  519.         FW_Boolean isShift = theMouseEvent.IsExtendModifier(ev);
  520.         FW_CRect selectRect;
  521.         rectShape.GetRectBounds(selectRect);
  522.         
  523.         CContentProxyIterator ite(fContainerPart->GetPartContent());
  524.         for (CProxy* proxy = ite.First(); ite.IsNotComplete(); proxy = ite.Next())
  525.         {
  526.             if (proxy->InSelectionRect(selectRect))
  527.             {
  528.                 if (proxy->IsSelected())
  529.                 {
  530.                     if (isShift)
  531.                     {
  532.                         DoRemove(ev, proxy);
  533.                         RenderHandles(ev, proxy);        // Turn Off
  534.                     }
  535.                 }
  536.                 else
  537.                 {
  538.                     DoAdd(ev, proxy);
  539.                     RenderHandles(ev, proxy);    // Turn on    
  540.                 }
  541.             }
  542.             else if (proxy->IsSelected() && !isShift)
  543.             {
  544.                 DoRemove(ev, proxy);
  545.                 RenderHandles(ev, proxy);        // Turn Off
  546.             }
  547.         }            
  548.         CalcCache(ev);
  549.     }
  550.     else
  551.     {
  552.         if (!theMouseEvent.IsExtendModifier(ev))
  553.             CloseSelection(ev);
  554.     }
  555. }
  556.  
  557. //----------------------------------------------------------------------------------------
  558. //    CContainerSelection::SelectionChanged
  559. //----------------------------------------------------------------------------------------
  560.  
  561. void CContainerSelection::SelectionChanged(Environment* ev)
  562. {
  563.     //--- Notify frames ---
  564.     GetPresentation(ev)->ContentUpdated(ev);
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. //    CContainerSelection::IsMouseInDraggableItem
  569. //----------------------------------------------------------------------------------------
  570.  
  571. FW_Boolean CContainerSelection::IsMouseInDraggableItem(Environment* ev, 
  572.                                                   FW_CFrame* frame, 
  573.                                                   const FW_CMouseEvent& theMouseEvent, 
  574.                                                   FW_Boolean inBackground)
  575. {    
  576.     fClickedHandle = 0;
  577.     fAnchorProxy = NULL;
  578.  
  579.     FW_CViewContext vc(ev, frame->GetContentView(ev), theMouseEvent.GetFacet(ev));
  580.  
  581.     // ----- Look first for a handle -----
  582.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  583.     frame->GetContentView(ev)->FrameToViewContent(ev, where);
  584.  
  585.     CProxy* clickedProxy = WhichHandle(ev, vc, where, fClickedHandle);
  586.     if (clickedProxy != NULL)
  587.     {
  588.         fAnchorProxy = clickedProxy;
  589.         return FALSE;            // if in a handle we won't drag
  590.     }
  591.     
  592.     // ----- then look for a selected proxy -----
  593.     CProxy* proxy = fContainerPart->WhichProxy(ev, vc, where, TRUE);
  594.     
  595.     if (proxy != NULL && proxy->IsSelected())
  596.     {
  597.         fAnchorProxy = proxy;
  598.         return TRUE;
  599.     }
  600.     
  601.     return FALSE;
  602. }
  603.  
  604. //----------------------------------------------------------------------------------------
  605. // CContainerSelection::UpdateSelectionOnMouseDown
  606. //----------------------------------------------------------------------------------------
  607.  
  608. void CContainerSelection::UpdateSelectionOnMouseDown(Environment* ev, 
  609.                                             const FW_CMouseEvent& mouseEvent,
  610.                                             ODFacet* embeddedFacet,
  611.                                             FW_Boolean inEmbeddedFrameBorder,
  612.                                             FW_Boolean inBackground)
  613. {
  614.     if (inEmbeddedFrameBorder)
  615.     {
  616.         fClickedHandle = 0;
  617.         fAnchorProxy = NULL;
  618.  
  619.         CProxy* theProxy = (CProxy*)fContainerPart->GetProxy(ev, embeddedFacet->GetFrame(ev));
  620.         FW_ASSERT(theProxy);
  621.         
  622.         if (!theProxy->IsSelected())
  623.             AddToSelection(ev, theProxy, TRUE);
  624.                 
  625.         fAnchorProxy = theProxy;
  626.     }
  627.     else
  628.     {
  629.         ODFacet* facet =  mouseEvent.GetFacet(ev);
  630.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  631.         FW_CViewContext vc(ev, frame->GetContentView(ev), facet);
  632.         FW_CPoint where = mouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  633.         frame->GetContentView(ev)->FrameToViewContent(ev, where);
  634.         
  635.         CProxy* clickedProxy = fContainerPart->WhichProxy(ev, vc, where, FALSE);
  636.         if (clickedProxy)
  637.         {
  638.             if (mouseEvent.IsExtendModifier(ev))
  639.             {
  640.                 if (clickedProxy->IsSelected())
  641.                 {
  642.                     RemoveFromSelection(ev, clickedProxy, !inBackground);
  643.                     if (clickedProxy == fAnchorProxy)
  644.                         fAnchorProxy = NULL;
  645.                 }
  646.                 else
  647.                 {
  648.                     AddToSelection(ev, clickedProxy, !inBackground);
  649.                     fAnchorProxy = clickedProxy;
  650.                 }
  651.             }
  652.             else if (!clickedProxy->IsSelected())
  653.             {
  654.                 fAnchorProxy = clickedProxy;
  655.                 CloseSelection(ev);
  656.                 AddToSelection(ev, clickedProxy, !inBackground);
  657.             }    
  658.         }
  659.     }
  660. }
  661.  
  662. //----------------------------------------------------------------------------------------
  663. //    CContainerSelection::DeleteSelection
  664. //----------------------------------------------------------------------------------------
  665.  
  666. void CContainerSelection::DeleteSelection(Environment* ev)
  667. {
  668.     CProxy* proxy;
  669.     while ((proxy = fSelectionContent->GetFirstProxy()) != NULL)
  670.     {
  671.         DoRemove(ev, proxy);                        // Remove from selection
  672.         fContainerPart->DeleteProxy(ev, proxy);        // delete the proxy
  673.     }
  674. }
  675.  
  676. //----------------------------------------------------------------------------------------
  677. //    CContainerSelection::IsOKtoEdit
  678. //----------------------------------------------------------------------------------------
  679.  
  680. FW_Boolean CContainerSelection::IsOKtoEdit(Environment* ev)
  681. {
  682.     // Check for a read-only part
  683.     if (fContainerPart->IsReadOnly(ev))
  684.         return false;
  685.  
  686.     return true;
  687. }
  688.  
  689. //----------------------------------------------------------------------------------------
  690. //    CContainerSelection::SelectContent
  691. //----------------------------------------------------------------------------------------
  692. void CContainerSelection::SelectContent(Environment* ev, CBaseContent* content)
  693. {
  694.     this->CloseSelection(ev);
  695.  
  696.     CContentProxyIterator it(content);
  697.     for (CProxy* proxy = it.First(); it.IsNotComplete(); proxy = it.Next())
  698.     {
  699.         this->AddToSelection(ev, proxy, TRUE);
  700.     }
  701. }
  702.  
  703. //----------------------------------------------------------------------------------------
  704. //    CContainerSelection::GetSelectionContent
  705. //----------------------------------------------------------------------------------------
  706.  
  707. CBaseContent* CContainerSelection::GetSelectionContent(Environment* ev)
  708. {
  709.     return fSelectionContent;
  710. }
  711.